home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 19 / CU Amiga Magazine's Super CD-ROM 19 (1998)(EMAP Images)(GB)[!][issue 1998-02].iso / CUCD / Online / pprx_WAD / WebAnimDesigner1_1.pprx < prev    next >
Text File  |  1997-12-05  |  33KB  |  1,090 lines

  1. /* Personal Paint Amiga Rexx script - Copyright © 1997, Andres Paabo. 'SaveAnimGif.pprx 1.7 script is copyright Cloanto (see bottom  portion  of this script)*/
  2.  
  3. /* $VER: WebAnimDesigner.pprx 1.1 */
  4.  
  5. /** ENG
  6.  This script is intended to assist in the creation of animated gifs for web pages.
  7.  NOTE this program does not create animated gifs itslf. It only helps design the anim or
  8.  animbrush that is used as a source for creating the animated gifs. The animated gifs
  9.  have to be created with other programs such as Cloanto's DefineAnimGif.pprx and
  10.  SaveAnimGif.pprx. However since this runs on Personal Paint. and for convenience, this
  11.  script will call on Personal Paint's 'SaveAnimGif.pprx' (in slightly modified form) and
  12.  pass information to it.
  13. */
  14.  
  15.  
  16.  
  17. IF ARG(1, EXISTS) THEN
  18.     PARSE ARG PPPORT
  19. ELSE
  20.     PPPORT = 'PPAINT'
  21.  
  22. IF ~SHOW('P', PPPORT) THEN DO
  23.     IF EXISTS('PPaint:PPaint') THEN DO
  24.         ADDRESS COMMAND 'Run >NIL: PPaint:PPaint'
  25.         DO 30 WHILE ~SHOW('P',PPPORT)
  26.              ADDRESS COMMAND 'Wait >NIL: 1 SEC'
  27.         END
  28.     END
  29.     ELSE DO
  30.         SAY "Personal Paint could not be loaded."
  31.         EXIT 10
  32.     END
  33. END
  34.  
  35. IF ~SHOW('P', PPPORT) THEN DO
  36.     SAY 'Personal Paint Rexx port could not be opened'
  37.     EXIT 10
  38. END
  39.  
  40. ADDRESS VALUE PPPORT
  41. OPTIONS RESULTS
  42. OPTIONS FAILAT 10000
  43.  
  44.  
  45.  
  46.  
  47.  
  48. /*********ANIM IS SET UP****WHAT TO DO NEXT***************************/
  49.  
  50.  
  51. openWAD= getclip('openWAD')
  52.  if openWAD = "" then DO
  53. /*******************ENSURES SCREEN NOT TOO SMALL & STUFF IS WITHIN SCREEN*****************/
  54. accept = 0
  55. GET 'SCREENW'
  56. scw = result
  57. if scw >= 640 then DO
  58.     GET 'SCREENH'
  59. sch = result
  60.     if sch >= 400 then DO
  61.         GET 'IMAGEW'
  62.             imgw = result
  63.             if imgw <= scw then DO
  64.             GET 'IMAGEH'
  65.             imgh = result
  66.                 if imgh <= sch then accept = 1
  67. END
  68. END
  69. END
  70. if accept = 0 then  DO
  71.     Requestnotify 'TITLE "CHANGE SCREEN or IMAGE SIZE" PROMPT  "For viewability, screen
  72.  size must be 640x 400 or greater, and image size equal or less the screen size"'
  73.     EXIT 0
  74.     END
  75. /********/
  76. call setclip('openWAD', 1)
  77.  
  78. END
  79. /********THE ABOVE IS DONE ONLY AT VERY START****IF OPENWAD =""****/
  80.  
  81. numcolors2=getclip('numcolors2')
  82. GET 'COLORS'
  83. numcolors=result 
  84. if numcolors = 256 then DO; RequestResponse 'PROMPT "You must start on the source page.
  85.  Proceed if okay. Cancel if not."';if rc~=0 then EXIT 0;END  
  86. if numcolors = numcolors2 then DO
  87.  switchenvironment
  88.  GET 'COLORS'
  89.  numcolors=result
  90. end
  91.  
  92. SETFRAMEPOSITION 1
  93.  
  94. REQUESTER:
  95. txt_gad_title = 'WEB ANIM DESIGNER 1.1 by A.Paabo for use with Personal Paint 7.+'
  96. txt_gad_transp = 'transparency'
  97. txt_gad_dispose = 'dispose'
  98. txt_gad_optimize = 'Optimization:'
  99. txt_gad_optimnone = '1.None (Constant size & position)'
  100. txt_gad_optimdelta = '3.Deltas (Varying size & position)'
  101. txt_gad_optimbndy= '2.Boundaries (Varying size & position)'
  102. txt_gad_operation = 'SELECT OPERATION:'
  103. txtnew = 'WEBANIMDESIGNER OPERATES ON THE CURRENT ANIMATION'
  104. txt_gad_preview = '1.SIMULATE animgif in 2nd environment'
  105. txt_gad_anbrush = 'Special Animbrush Operations '
  106. txt_gad_anbrushnone = '(When selected, overrides above operations)'
  107. txt_gad_pickup = '2.pick up web anim as annotated animbrush'
  108. txt_gad_animload = '1.make current animbrush into WAD anim'
  109. txt_gad_final = '2.MAKE ANIMGIF via Cloanto SaveAnimGif'
  110. txt_gad_drawrect = 'simulation:show frame rectangles'
  111. txt_gad_curglobal = 'define global rectangle'
  112. txt_gad_curglobal0 = '(use current global rectangle)  '
  113. txt_gad_curglobal1 = '1.let WAD determine new from anim'
  114. txt_gad_curglobal2 = '2. User-define new with mouse'
  115.  
  116.  
  117. transpcol = getclip('transpcol'); if transpcol = "" then transpcol=0
  118. X0 = getclip('X0')
  119. Y0 = getclip('Y0')
  120. X1 = getclip('X1')
  121. Y1 = getclip('Y1')
  122. GETFRAMES
  123. frames=result 
  124. transp=getclip('transp')
  125.  if transp = "" then transp = 1
  126. dispose = getclip('dispose')
  127.  if dispose = "" then dispose = 1
  128. optimization= getclip('optimization')
  129.  if optimization="" then optimization = 0
  130. drawrect= getclip('drawrect')
  131.  if drawrect="" then drawrect=1
  132. curglobal = getclip('curglobal')
  133.  if curglobal="" then curglobal=0
  134.  anbrush=0
  135. operation = getclip('operation')
  136. if operation = "" then operation =0 
  137. Request '"'txt_gad_title'" ' ||,
  138.     ' "TEXT = ""'txtnew'"" '||,
  139.    ' CHECK = ""'txt_gad_transp'"", 'transp' ' ||,
  140.         ' CHECK = ""'txt_gad_dispose'"", 'dispose' ' ||,
  141.        ' CYCLE = ""'txt_gad_optimize'"", 3, 'optimization', ""'txt_gad_optimnone'"",""'txt_gad_optimbndy'"", ""'txt_gad_optimdelta'"" ' ||,  
  142.  ' CYCLE = ""'txt_gad_curglobal'"", 3, 'curglobal', ""'txt_gad_curglobal0'"", ""'txt_gad_curglobal1'"", ""'txt_gad_curglobal2'"" ' ||,
  143. ' VSPACE = 8 ' ||,
  144.  ' CYCLE = ""'txt_gad_operation'"", 2, 'operation',""'txt_gad_preview'"",  ""'txt_gad_final'"" '||,
  145.     ' VSPACE = 8 ' ||,
  146. ' CHECK = ""'txt_gad_drawrect'"", 'drawrect' ' ||,
  147. ' SEPARATOR ' ||,
  148.   ' CYCLE = ""'txt_gad_anbrush'"", 3, 'anbrush', ""'txt_gad_anbrushnone'"", ""'txt_gad_animload'"", ""'txt_gad_pickup'"" "'  
  149.                    if rc~=0 then EXIT 0
  150.          if rc = 0 then DO
  151.             transp = RESULT.1
  152.             dispose = RESULT.2
  153.             optimization = RESULT.3
  154.              curglobal = RESULT.4
  155.             operation = RESULT.5
  156.                drawrect = RESULT.6
  157.                 anbrush = RESULT.7
  158.                               END
  159. call setclip('transp', transp)
  160. call setclip('dispose', dispose)
  161. call setclip('operation', operation)
  162. call setclip('optimization', optimization)
  163. call setclip('drawrect', drawrect)
  164. call setclip('curglobal', curglobal)
  165. call setclip('anbrush', anbrush)
  166.  
  167. if anbrush = 1 then DO
  168.      GetBrushAttributes 'FRAMES'
  169.     frames = RESULT
  170.     IF frames < 2 then DO
  171.         Requestnotify 'PROMPT "You selected animbrush but there is no animbrush present.
  172.  We exit."'
  173.         EXIT 0
  174.         END
  175.     if frames ~< 2 then call BRUSHLOADER
  176.     END
  177.  
  178. if anbrush = 2 then DO
  179.         Getframes
  180.     frames = result
  181.     if frames < 2 then DO
  182.         Requestnotify 'PROMPT "You selected to pick up an animbrush but there is no animation present"'
  183.         EXIT
  184.         END
  185.     if X0 = "" then DO
  186.         Requestnotify 'PROMPT "No global rectangle is defined. We do not know what area to pick up."'
  187.         EXIT
  188.         END 
  189.     call PICKUPABRUSH  /*does not continue to save as there is an anbrush=2 block*/
  190. END
  191. if transp= 0 then SET '"TRANSP=0"'      
  192.  if transp=1 then SET '"TRANSP=1"'
  193. Getframes
  194. frames = result
  195. if frames <2 then DO
  196.     Requestnotify 'PROMPT "There is no animation to work on. Load an animation, or make
  197.  one from animbrush"'
  198.     EXIT
  199.     END
  200. if curglobal = 0 then DO
  201.         if X0 = "" then DO
  202.                     Requestnotify 'PROMPT "There  is no previous global rectangle
  203.  definition. You must define the global rectangle. Try again."'
  204.                     EXIT
  205.                    END
  206.                     END
  207.  
  208. if  curglobal = 1 then call GLOBALAREA
  209. if curglobal = 2 then call DEFINERECT
  210.  
  211.  
  212. if operation = 1 then CALL PICKUPABRUSH   /*saveanimgif bypasses it all*/
  213.  
  214.  
  215. if optimization = 1 then DO
  216.     if transp =0 then Requestnotify 'PROMPT "Boundaries optimization in settings other
  217.  than transp=1 and dispose=1 may produce a webanim result different from the source Amiga
  218.  animation."'
  219. END
  220. if optimization = 2 then DO
  221.     if transp =1 then Requestnotify 'PROMPT "Deltas optimization in settings other than
  222.  transp=0 and dispose=0 may produce a webanim result different from the source Amiga
  223.  animation."'
  224. END
  225.  
  226. SWITCHENVIRONMENT          
  227. DELETEFRAMES ALL FORCE
  228. CLEARIMAGE
  229. if numcolors < 256 then numcolors2 = numcolors*2
  230. if numcolors = 256 then numcolors2 = numcolors
  231. Set 'FORCE "COLORS='numcolors2'"'
  232.     col = '153 153 153'
  233.     col2 = '204 204 204'
  234.     Setcolors 'FROM "'numcolors2-1'" COLORS "'col'"'
  235.      Setcolors 'FROM "'numcolors2-2'" COLORS "'col2'"'
  236.  
  237. SETPEN 'BACKGROUND' numcolors2-1
  238. call setclip('numcolors2', numcolors2) 
  239. Clearimage 
  240. CALL TEXTSRECT
  241. ADDFRAMES 
  242. SWITCHENVIRONMENT
  243.  
  244.  
  245. /*********BEGIN***********/
  246.  
  247.  
  248. SETFRAMEPOSITION 1
  249.  
  250. /*************************/
  251. if optimization=0 then DO
  252.         
  253.     DO frm = 1 to frames
  254.         SETFRAMEPOSITION frm
  255.         GETFRAMEDELAY frm
  256.         delay = result
  257.          Definebrush x0 y0 x1 y1
  258.        setbrushhandle UPPERLEFT
  259.         SWITCHENVIRONMENT
  260.         SETFRAMEPOSITION frm
  261.         SETFRAMEDELAY delay
  262.         usebrushpalette
  263.         remapimage
  264.         if dispose = 0 then Putbrush x0 y0
  265.                if frm < frames then  ADDFRAMES 1 AFTER
  266.           if dispose = 1 then  Putbrush x0 y0 
  267.         SWITCHENVIRONMENT      
  268.                END
  269.  END
  270. /*********BOUNDARIES*****************/
  271. if optimization=1 then DO
  272.         
  273.     DO frm = 1 to frames
  274.         SETFRAMEPOSITION frm
  275.           GETFRAMEDELAY frm
  276.         delay = result
  277.         GetImageAttributes 'BOUNDARIES'
  278.         PARSE VAR RESULT bx0 by0 bx1 by1 rest
  279.         if bx0 <= X0 then bx0 = X0
  280.         if by0 <= Y0 then by0 = Y0
  281.          if bx0 >= X1 then bx0 = X1
  282.         if by0 >= Y1 then by0 = Y1
  283.         if bx1 >= X1 then bx1 = X1
  284.         if by1 >= Y1 then by1 = Y1
  285.          if bx1 <= X0 then bx1 = X0
  286.         if by1 <= Y0 then by1 = Y0
  287.          Definebrush bx0 by0 bx1 by1
  288.        setbrushhandle UPPERLEFT
  289.         SWITCHENVIRONMENT
  290.         SETFRAMEPOSITION frm
  291.         SETFRAMEDELAY delay
  292.         usebrushpalette
  293.         remapimage
  294.           if dispose = 0 then Putbrush bx0 by0
  295.                if frm < frames then  ADDFRAMES 1 AFTER
  296.           if dispose = 1 then  Putbrush bx0 by0
  297.             freebrush force
  298.             Setpen 'FOREGROUND' numcolors2-3
  299.             if drawrect=1 then Drawrectangle bx0 by0 bx1 by1
  300.             SWITCHENVIRONMENT
  301.                   END
  302.  END 
  303.  
  304. /********DELTA******************/
  305. if optimization=2 then DO
  306.   tbmap.0 = 0
  307. tbmap.1 = 0
  308. GET 'COLORS'
  309. bcolors = result
  310. /*get bdepth from number of colros*/
  311. DO bdepth = 1 to 8
  312. if bcolors = (2 ** bdepth) THEN
  313. BREAK
  314. END
  315. bwidth = X1-X0
  316. bheight = Y1-Y0
  317.  
  318. AllocateBitmap bwidth bheight bdepth
  319. tbmap.0 = result
  320. AllocateBitmap bwidth bheight bdepth
  321. tbmap.1 = result
  322. SETFRAMEPOSITION 1
  323.   GETFRAMEDELAY 1
  324.         delay = result
  325. DefineBrush X0 Y0 X1 Y1
  326. setbrushhandle upperleft
  327. SWITCHENVIRONMENT
  328. if dispose=1 then ADDFRAMES 1 AFTER
  329. usebrushpalette
  330. remapimage
  331. Putbrush X0 Y0
  332. if dispose = 0 then ADDFRAMES 1 AFTER
  333. SETFRAMEDELAY delay
  334. SWITCHENVIRONMENT
  335.  
  336. DO frm = 1 to frames-1
  337. SETFRAMEPOSITION frm
  338.  GetBitmap X0 Y0 X1-1 Y1-1 'BITMAP' tbmap.0
  339. SETFRAMEPOSITION frm+1
  340. GetBitmap X0 Y0 X1-1 Y1-1 'BITMAP' tbmap.1
  341. GetBitmapDelta  tbmap.0 tbmap.1
  342. PARSE VAR RESULT delx0 dely0 delx1 dely1
  343.  
  344. if delx0 < 0 then DO  /*means a value of -1 meaning identical*/
  345.         delx0 = 0
  346.         dely0 = 0
  347.         delx1 = 0
  348.         dely1 = 0
  349.         END
  350.  
  351. dx0 = X0 + delx0 
  352. dy0 = Y0 + dely0
  353. dx1 = X0 + delx1 + 1
  354. dy1 = Y0 + dely1 + 1
  355.  
  356.         if dx0 <= X0 then dbx0 = X0
  357.         if dy0 <= Y0 then dy0 = Y0
  358.         if dx0 >= X1 then dx0 = X1
  359.         if dy0 >= Y1 then dy0 = Y1
  360.         if dx1 >= X1 then dx1 = X1
  361.         if dy1 >= Y1 then dy1 = Y1
  362.          if dx1 <= X0 then dx1 = X0
  363.         if dy1 <= Y0 then dy1 = Y0
  364. Definebrush dx0 dy0 dx1 dy1
  365.          SwitchENvironment /*to switch env*/
  366.         SETFRAMEPOSITION frm+1
  367.  GETFRAMEDELAY frm
  368.         delay = result
  369.        Usebrushpalette
  370.         remapimage
  371.         SetBrushHandle UPPERLEFT
  372.                 if dispose = 0 then PutBrush dx0 dy0 
  373.                 if frm <frames-1 then ADDFRAMES 1 AFTER
  374.                 if dispose = 1 then PutBrush dx0 dy0 
  375.                 FreeBrush FORCE
  376.                 SETPEN 'FOREGROUND' numcolors2-3
  377.                 if drawrect=1 then DrawRectangle dx0 dy0 dx1 dy1 /*the delta*/
  378.             SETFRAMEDELAY delay
  379.             SWITCHENVIRONMENT
  380.  
  381.  
  382.     END
  383.   
  384.  END
  385. /***********************/
  386.  
  387.   SwITCHENVIRONMENT 
  388.   SETFRAMEPOSITION 1
  389.     PLAY 
  390.  
  391.  
  392.  
  393. /***********************************/
  394.  
  395.  
  396.  
  397. /*********************************************/
  398. EXIT
  399. /*****************************************/
  400. GLOBALAREA:
  401.     RequestResponse 'TITLE "AUTOMATIC DETERMINATION OF SMALLEST OVERALL AREA" PROMPT
  402.  "This process requires the anim is surrounded by a clear, clean,  field of background
  403.  color. If not, cancel, and use user-define method instead."'
  404.     If rc~=0 then EXIT
  405.                  maxdx = 0
  406.                 maxdy= 0
  407.                 mindx = 4000
  408.                 mindy = 4000
  409.  DO frm = 1 to frames
  410.             SETFRAMEPOSITION frm
  411.             GetImageAttributes 'BOUNDARIES'
  412.             PARSE VAR RESULT dx0 dy0 dx1 dy1 rest
  413.             if dx0 < mindx then mindx = dx0
  414.             if dy0 < mindy then mindy = dy0
  415.             if dx1 > maxdx then maxdx = dx1
  416.             if dy1 > maxdy then maxdy = dy1
  417.               END
  418.             X0 = mindx
  419.             Y0 = mindy
  420.             X1 = maxdx
  421.             Y1 = maxdy 
  422.         
  423.            call setclip('X0', X0)
  424.            call setclip('Y0', Y0)    
  425.             call setclip('X1', X1)
  426.             call setclip('Y1', Y1) 
  427. rc=0   
  428. RETURN
  429. /***********************************************/
  430. TEXTSRECT:
  431. GET 'IMAGEW'
  432. imgw = RESULT
  433. Xmid = TRUNC(imgw/2)
  434. SETPEN 'FOREGROUND' numcolors2-2
  435. Text 'TEXT "WebAnimDesigner 1.1 by Andres Pääbo (c)97 -- email: paabo@bancom.net" "fonts:" "times" "10" "of" "'Xmid'" "20" CENTER'
  436. Text 'TEXT "SIMULATION OF ANIM GIF ON WEB PAGE" "fonts:" "times" "20" "of" "'Xmid'" "40" CENTER'
  437. Text 'TEXT "(IF ACTIVE)LARGE RECTANGLE SHOWS GLOBAL ANIMGIF SIZE.SMALLER RECTANGLES SHOW FRAME SIZES" "fonts:" "times" "10" "of" "'Xmid'" "60" CENTER'
  438. if transp=1 then DO
  439. if dispose = 1 then Text 'TEXT "angif setting at TRANSPARENCY=1 DISPOSE=1" "fonts:" "times" "15" "of" "'Xmid'" "70" CENTER'
  440. if dispose = 0 then Text 'TEXT "angif setting at TRANSPARENCY=1 DISPOSE=0" "fonts:" "times" "15" "of" "'Xmid'" "70" CENTER'
  441.     END
  442. if transp=0 then DO
  443. if dispose = 1 then Text 'TEXT "angif setting at TRANSPARENCY=0 DISPOSE=1" "fonts:" "times" "15" "of" "'Xmid'" "70" CENTER'
  444. if dispose = 0 then Text 'TEXT "angif setting at TRANSPARENCY=0 DISPOSE=0" "fonts:" "times" "15" "of" "'Xmid'" "70" CENTER'
  445. eND
  446. if optimization = 0 then Text 'TEXT "OPTIMIZATION=NONE (CONST FRAME & POSTITION)" "fonts:" "times" "15" "of" "'Xmid'" "85" CENTER' 
  447. if optimization =1  then Text 'TEXT "OPTIMIZATION=BOUNDARIES" "fonts:" "times" "15" "of" "'Xmid'" "85" CENTER' 
  448. if optimization = 2 then Text 'TEXT "OPTIMIZATION=DELTA" "fonts:" "times" "15" "of" "'Xmid'" "85" CENTER' 
  449.  
  450. freebrush FORCE
  451. if drawrect=1 then DrawRectangle X0 Y0 X1 Y1  
  452. RETURN
  453. /*********************************************/
  454.  
  455.    
  456. /*************************************************/
  457. BRUSHLOADER:
  458.  
  459.  
  460. /**if frames ~< 2 then continue as originally***/
  461.  
  462.  
  463. CLEARIMAGE
  464. FREEENVIRONMENT FORCE
  465. SWITCHENVIRONMENT 
  466.  
  467.  
  468.  
  469.  
  470. GetbrushAttributes 'COLORS'
  471. numcolors = RESULT
  472. Set 'FORCE "COLORS='numcolors'"'
  473. copyenvironment FORCE
  474.  
  475. Set 'FORCE "TRANSP= 1"'
  476. GET 'IMAGEW'
  477. imgw = RESULT
  478. GET 'IMAGEH'
  479. imgh = RESULT
  480. imgmid = TRUNC(imgw/2)
  481.  
  482. GetBrushAttributes 'FRAMES'
  483. frames = RESULT
  484. GetBrushAttributes WIDTH
  485. width = result
  486. if width > imgw-100 then DO; Requestnotify 'TITLE "ANIMBRUSH TO WIDE" PROMPT "The animbrush is too
  487.  wide. Use larger screen size"';EXIT 0; END
  488. GetBrushAttributes HEIGHT
  489. height = RESULT
  490. if height > imgh-100 then DO; Requestnotify 'TITLE "ANIMBRUSH TO WIDE" PROMPT "The animbrush is too
  491.  high. Use larger screen size."'; EXIT 0; END
  492. x0 = TRUNC((imgw-width)/2)
  493. y0 = TRUNC((imgh-height)/2)
  494. x1 = x0 + width
  495. y1 = y0 + height
  496. setbrushhandle UPPERLEFT
  497.  
  498.  
  499. UseBrushPalette
  500. GetBrushAttributes 'TRANSPARENCY'
  501.             transp = RESULT
  502.                 IF transp=0 then transpcol = 0
  503.                If transp >0 then DO
  504.                 GetBrushAttributes 'TRANSPARENTCOLOR'
  505.                 transpcol = RESULT
  506.                 setpen 'BACKGROUND' transpcol
  507.                     END
  508. /************CLEAR TO ABRS TRANSP COLOR & STAMP DOWN*************************/
  509. GetBrushInfo 'ANNOTATION'
  510. frame_annot = RESULT
  511.  
  512. delayannot = 0
  513. loop = -1
  514. delay. = 0
  515. IF WORD(frame_annot, 1) = 'LOOP' & WORD(frame_annot, 3) = 'DELAY' THEN DO
  516. delayannot=1
  517.     loop = WORD(frame_annot, 2)
  518.     IF ~DATATYPE(loop, 'W') THEN
  519.         loop = -1
  520.     DO frm = 1 TO frames
  521.         del = WORD(frame_annot, 3+frm)
  522.         IF DATATYPE(del, 'W') THEN
  523.             delay.frm = del
  524. delay.frm = TRUNC(delay.frm*(60/100))
  525.     END
  526. END
  527. SETPEN 'BACKGROUND' transpcol
  528. ClearImage
  529. ADDFRAMES frames AFTER
  530. DO frm = 1 TO frames
  531. SETFRAMEPOSITION frm
  532. if delayannot=1 then SETFRAMEDELAY delay.frm
  533. if delayannot = 0 then SETFRAMEDELAY 10
  534. SetBrushAttributes 'FRAMEPOSITION' frm
  535. Usebrushpalette
  536. Putbrush X0 y0
  537. END
  538.  
  539. SETFRAMEPOSITION 1
  540.  
  541.             call setclip('X0', X0)
  542.            call setclip('Y0', Y0)    
  543.             call setclip('X1', X1)
  544.             call setclip('Y1', Y1) 
  545.             call setclip('openWAD', 1)
  546.             call setclip('operation', 1)
  547.             call setclip('curglobal', 0 )      
  548. freebrush  /*not needed as we make the preview version from the image*/
  549.  
  550. PLAY 3
  551.  
  552. Requestnotify 'PROMPT " An anim has been established from the animbrush on the center of the page,
  553.  making the original animbrush area as the initial global rectangle. Reenter W.A.D. and continue."'
  554.  
  555.  
  556. EXIT 0
  557. /******************create pickup rectangle**********************/
  558.  
  559. DEFINERECT:
  560. Requestnotify 'PROMPT "Define the overall (global) rectangle with mouse"'
  561. SetCurrentBrush 'RECTANGULAR WIDTH 1 HEIGHT 1'
  562.  
  563. GetPen 'FOREGROUND'
  564. savepen = RESULT
  565. Get 'COLORS'
  566. SetPen 'FOREGROUND' RESULT-1
  567.  
  568. DisableTools
  569.  
  570.     WaitForClick 'DOWN POINT SHOWBRUSH'
  571.     IF RC = 0 THEN DO
  572.         PARSE VAR RESULT button x0 y0 .
  573.         prev_x1 = x0
  574.         prev_y1 = y0
  575.         drawn = 0
  576.  
  577.          DO FOREVER
  578.             GetMousePosition
  579.             PARSE VAR RESULT x1 y1 .
  580.  
  581.             IF x1 ~= prev_x1 | y1 ~= prev_y1 | ~drawn THEN DO
  582.                 If drawn THEN
  583.                     Undo
  584.                 DrawRectangle x0 y0 x1 y1 'COMPLEMENT'
  585.                 prev_x1 = x1
  586.                 prev_y1 = y1
  587.                 drawn = 1
  588.                        END
  589.  
  590.         ELSE WaitForEvent
  591.         GetMouseButton
  592.         IF RESULT ~= button THEN
  593.          LEAVE
  594.     END
  595.        
  596.      IF x0 > x1 THEN DO
  597.             t = x0
  598.             x0 = x1
  599.             x1 = t
  600.                    END
  601.         IF y0 > y1 THEN DO
  602.             t = y0
  603.             y0 = y1
  604.             y1 = t
  605.                    END
  606.       call setclip('X0', X0)
  607.            call setclip('Y0', Y0)    
  608.             call setclip('X1', X1)
  609.             call setclip('Y1', Y1) 
  610.  
  611. Undo
  612. RETURN
  613.  
  614. /****************************************************/
  615. PICKUPABRUSH:
  616.  
  617. GETFRAMES
  618. frames = result
  619. Setframeposition 1
  620. posit = 1
  621. X0 = GETCLIP('X0')
  622. Y0 = GETCLIP('Y0')
  623. X1 = GETCLIP('X1')
  624. Y1 = GETCLIP('Y1')
  625. /********get animation project info if exists****************/
  626. GetProjectInfo 'COPYRIGHT'
  627. annot = RESULT
  628. /***get time delays from source animation, convert  to 100ths if asked***/
  629. DO frm = 1 to frames  
  630. GetFrameDelay 'FRAME' frm
  631. del = RESULT
  632. delay.frm = TRUNC((del * 100/60) + 0.5)
  633. END
  634. /*******make animbrush********/
  635. DefineBrush  X0 Y0 X1 Y1 'FRAMES' frames 
  636. /*******annotate animbrush with delay timings********/
  637. loop = 1
  638. frame_annot = 'LOOP' loop 'DELAY'
  639. 
  640. DO frm = 1 TO frames 
  641.     frame_annot = frame_annot delay.frm
  642. END
  643. SetBrushInfo 'ANNOTATION "'frame_annot'"'
  644. SetBrushInfo 'COPYRIGHT "'annot'"'
  645.  
  646. if anbrush = 2 then DO
  647.     Requestnotify 'PROMPT "an annotated animbrush has been picked up"'
  648.         EXIT
  649.         END
  650.  
  651.  
  652. /****************continue into other scripts*********************/
  653. /*********NOTE: THESE CALL ON THIRD PARTY SCRIPTS THAT***********/
  654. /**************ACTUALLY CREATE THE ANIMATED GIFS.*****************/
  655.  
  656. call setclip('dispose', dispose)
  657. call setclip('optimization', optimization)
  658.  
  659.  
  660.  
  661. CALL WADSaveAnimGif
  662.  
  663.  
  664. EXIT 0
  665.  
  666.  
  667. WADSaveAnimGif:
  668. /**********INFO FROM WEB ANIM DESIGNER***********/
  669. /*****not provided in annotated animbrush********/
  670. /*optimization = getclip('optimization');dispose = getclip('dispose')*/
  671. if optimization = 0 then optimname = 'NONE'
  672. if optimization = 1 then optimname = 'BOUNDARIES'
  673. if optimization = 2 then optimname = 'DELTA'
  674. REQUESTRESPONSE 'TITLE "SETTINGS TO BE USED" PROMPT "optimization='optimname' dispose='dispose' transp='transp'"'
  675. /**************************************************/
  676.  
  677. /************MODIFIED SaveANimGif.pprx*************************************/
  678. /****not part of this program. Provided for your convenience**********/
  679.  
  680.  
  681. /* Personal Paint Amiga Rexx script - Copyright © 1996, 1997 Cloanto Italia srl */
  682.  
  683. /* $VER: MODIFIED SaveAnimGif.pprx 1.7 */
  684. /*MODIFIED SaveAnimGif.pprx 1.7. The modifications are simple ones to allow the above host program
  685.  to pass to it the parameters this program uses. Since the parameteers are passed to it, the
  686.  settings requester is not needed, and that portion of the script has been removed. Also, to
  687.  permit the creation of various situations other than just delta-nontransp-nodispose and
  688.  boundaries-transp-dispose, explicit control of the host's variable 'optimization' is simply
  689.  introduced, and more output possibilities than the above two are permitted. All modified sections
  690.  are marked*/
  691.  
  692. /****MODIFICATION****remove entry script since it is already acheived at the top of this overall script***/
  693. /*******MODIFICATION ****as settings requester removed, gadget texts relating to it removed. These
  694.  remain. Non English excluded in this version***/
  695.     txt_title_req  = 'Save GIF Anim-Brush'
  696.     txt_err_oldclient = 'This script requires a newer_version of Personal Paint'
  697.     txt_err_oldlib    = 'This script requires a newer_version of the GIF library'
  698.     txt_err_notabsh   = 'The current brush_is not an anim-brush'
  699.     txt_err_notemp    = 'No space for temporary brush'
  700.     txt_err_nomem     = 'Not enough memory'
  701.     txt_err_nosave    = 'File I/O error'
  702.  
  703.  
  704. Version 'REXX'
  705. IF RESULT < 7 THEN DO
  706.     RequestNotify 'PROMPT "'txt_err_oldclient'"'
  707.     EXIT 10
  708. END
  709.  
  710. LockGUI
  711. GetBrushAttributes 'FRAMES'
  712. frames = RESULT
  713.  
  714. IF frames < 2 THEN DO
  715.     RequestNotify 'PROMPT "'txt_err_notabsh'"'
  716.     UnlockGUI
  717.     EXIT 0
  718. END
  719.  
  720. GetBrushNumber
  721. bshnum = RESULT
  722.  
  723. SetCurrentBrush 'UNUSED'
  724. IF RC ~= 0 THEN DO
  725.     RequestNotify 'PROMPT "'txt_err_notemp'"'
  726.     UnlockGUI
  727.     EXIT 0
  728. END
  729. GetBrushNumber
  730. tbshnum = RESULT
  731.  
  732. SetCurrentBrush 'BRUSH' bshnum
  733. GetBrushInfo 'ANNOTATION'
  734. frame_annot = RESULT
  735.  
  736. loop = -1
  737. delay. = 0
  738. IF WORD(frame_annot, 1) = 'LOOP' & WORD(frame_annot, 3) = 'DELAY' THEN DO
  739.     loop = WORD(frame_annot, 2)
  740.     IF ~DATATYPE(loop, 'W') THEN
  741.         loop = -1
  742.     DO frm = 1 TO frames
  743.         del = WORD(frame_annot, 3+frm)
  744.         IF DATATYPE(del, 'W') THEN
  745.             delay.frm = del
  746.     END
  747. END
  748. use_loop = (loop >= 0)
  749. IF loop < 0 THEN
  750.     loop = 0
  751.  
  752. fnlen = LENGTH(frames)
  753. dsel = 1
  754. do_req = 1
  755. deltype = 0
  756.  
  757. GetBrushInfo 'COPYRIGHT'
  758. annot = RESULT
  759. max_annot_size = LENGTH(annot) * 2
  760. IF max_annot_size < 200 THEN
  761.     max_annot_size = 200
  762.  
  763. GetBrushAttributes 'TRANSPARENCY'
  764. transp = RESULT
  765. IF transp ~= 1 THEN
  766.     transp = 0
  767.  
  768. /*****MODIFICATION*****all matters pertaining to the settings requester have been removed since
  769.  the host provides all settings data. We continue at the following lines*****/
  770.  
  771.  
  772. IF ~use_loop THEN
  773.     loop = -1
  774. frame_annot = 'LOOP' loop 'DELAY'
  775. DO frm = 1 TO frames
  776.     frame_annot = frame_annot delay.frm
  777. END
  778. SetBrushInfo 'ANNOTATION "'frame_annot'"'
  779.  
  780.  
  781. RequestFile '"'txt_title_req'" SAVEMODE'
  782. IF RC = 0 THEN DO
  783.     PARSE VALUE RESULT WITH '"' fname '"'
  784.     tempfile = 'T:PP_AnGif.'PRAGMA('ID')
  785.  
  786.     GetBrushAttributes 'FRAMEFIRST'
  787.     sv_frmin = RESULT
  788.     GetBrushAttributes 'FRAMELAST'
  789.     sv_frmax = RESULT
  790.     GetBrushAttributes 'LENGTH'
  791.     sv_frlen = RESULT
  792.     GetBrushAttributes 'FRAMEPOSITION'
  793.     sv_frpos = RESULT
  794.     Get 'ICONS'
  795.     sv_icons = RESULT
  796.  
  797.     GetBrushAttributes 'WIDTH'
  798.     bwidth = RESULT
  799.     GetBrushAttributes 'HEIGHT'
  800.     bheight = RESULT
  801.  
  802.     GetBrushAttributes 'TRANSPARENTCOLOR'
  803.     transpcol = RESULT
  804.     GetBrushAttributes 'COLORS'
  805.     bcolors = RESULT
  806.     plt_size = bcolors * 3
  807.  
  808.     Get 'PATHBSH'
  809.     PARSE VAR RESULT '"' sv_pathbsh '"'
  810.  
  811. /*****MODIFICATION****we remove the following lines because they only provide two options
  812.     IF transp = 1 THEN
  813.         pckinfo = '09'x
  814.     ELSE
  815.         pckinfo = '00'x  ******/
  816.  
  817. /*******MODIFICATION*****we replace them with these lines which provide a few more*******/
  818.     if transp = 0 then DO
  819.     if dispose = 0 then pckinfo = '06'x /*notrans nodisp*/
  820.      if dispose = 1 then pckinfo = '08'x /*notrans & dispose*/
  821.             END
  822.     if transp = 1 then DO
  823.     if dispose = 0 then pckinfo = '05'x /*trans & nodispose*/
  824.     if dispose = 1 then if transp = 1 then pckinfo = '09'x /*trans & dispose*/
  825.             END
  826. /************************************/    
  827.  
  828.  
  829.  
  830.     DO bdepth = 1 TO 8
  831.         IF bcolors = (2 ** bdepth) THEN
  832.             BREAK
  833.     END
  834.  
  835.     tbmap.0 = 0
  836.     tbmap.1 = 0
  837.     tbnum = 0
  838.     gfile_open = 0
  839.     global_plt = ''
  840.     err_msg = ''
  841.  
  842.     SIGNAL ON Break_C
  843.  
  844.     AllocateBitmap bwidth bheight bdepth
  845.     IF RC = 0 THEN DO
  846.         tbmap.0 = RESULT
  847.  
  848.         AllocateBitmap bwidth bheight bdepth
  849.         IF RC = 0 THEN DO
  850.             tbmap.1 = RESULT
  851.  
  852.             SetBrushAttributes 'FRAMEFIRST 1 FRAMELAST' frames 'LENGTH' frames
  853.             Set '"ICONS = 0"'
  854.  
  855.             DO frm = 1 TO frames
  856.                 SetCurrentBrush 'BRUSH' bshnum
  857.                 IF RC ~= 0 THEN DO
  858.                     err_msg = txt_err_nomem
  859.                     BREAK
  860.                 END
  861.  
  862.                 SetBrushAttributes 'FRAMEPOSITION' frm
  863.                 IF RC ~= 0 THEN DO
  864.                     err_msg = txt_err_nomem
  865.                     BREAK
  866.                 END
  867.  
  868.                 GetBitmap '0 0 BITMAP' tbmap.tbnum 'FROMBRUSH'
  869.                 tbnum = 1 - tbnum
  870.  
  871.                 GetBrushColors
  872.                 local_plt = RESULT
  873.  
  874.                 IF frm = 1 THEN DO
  875.                     dx0 = 0
  876.                     dy0 = 0
  877.                     dx1 = bwidth - 1
  878.                     dy1 = bheight - 1
  879.                     global_plt = local_plt
  880.                 END
  881.                 ELSE DO
  882. /*****MODIFICATION**to make pgm obey host variable= optimization*******/
  883.                     /*IF transp = 1 THEN*/
  884.                         if optimization < 2 then GetBrushAttributes 'BOUNDARIES'
  885.                     ELSE
  886.                         GetBitmapDelta tbmap.0 tbmap.1
  887. /****MODIFICATION***to force using entire image values if optimization=0**********/
  888.                     if optimization > 0 then PARSE VAR RESULT dx0 dy0 dx1 dy1 .
  889. /********and that's all!****basically the original program functions as always**************/
  890.                     IF dx0 < 0 THEN DO
  891.                         dx0 = 0
  892.                         dy0 = 0
  893.                         dx1 = 0
  894.                         dy1 = 0
  895.                     END
  896. /********MODIFICATION***remove the IExplorer bug accomodation**which creates problems for
  897.  multiple palette animbrushes in nontransp mode*****/
  898.  
  899.                 END
  900.  
  901.                 SetCurrentBrush 'BRUSH' tbshnum
  902.                 IF RC ~= 0 THEN DO
  903.                     err_msg = txt_err_nomem
  904.                     BREAK
  905.                 END
  906.  
  907.                 CopyBrush bshnum dx0 dy0 dx1 dy1 'NOFRAMES'
  908.                 IF RC ~= 0 THEN DO
  909.                     err_msg = txt_err_nomem
  910.                     BREAK
  911.                 END
  912.  
  913.                 SaveBrush tempfile 'FORCE QUIET NOPROGRESS FORMAT "GIF" OPTIONS "GIF89=1" "PROGDSP=0" "SCRFMT=0"'
  914.                 IF RC ~= 0 THEN DO
  915.                     IF RC = 46 | RC = 47 THEN
  916.                         err_msg = txt_err_oldlib
  917.                     ELSE
  918.                         err_msg = txt_err_nosave
  919.                     BREAK
  920.                 END
  921.  
  922.                 IF ~OPEN('tfile', tempfile, 'R') THEN DO
  923.                     err_msg = txt_err_nosave
  924.                     BREAK
  925.                 END
  926.  
  927.                 IF frm = 1 THEN DO
  928.                     IF ~OPEN('gfile', fname, 'W') THEN DO
  929.                         err_msg = txt_err_nosave
  930.                         BREAK
  931.                     END
  932.                     gfile_open = 1
  933.                     data = READCH('tfile', 13)      /* sign + screen descriptor */
  934.                     bxpix = BITOR(BITAND(SUBSTR(data, 11, 1), '07'x), '80'x)
  935.                     CALL WRITECH('gfile', data)
  936.  
  937.                     plt_data = READCH('tfile', plt_size)    /* palette */
  938.                     CALL WRITECH('gfile', plt_data)
  939.                     do_plt = 0
  940.  
  941.                     IF use_loop THEN
  942.                         CALL WRITECH('gfile', '21FF0B'x || 'NETSCAPE2.0' || '0301'x || IntelWord(loop) || '00'x)
  943.  
  944.                     IF annot ~= '' THEN DO      /* annotation */
  945.                         CALL WRITECH('gfile', '21FE'x)
  946.                         alen = LENGTH(annot)
  947.                         apos = 1
  948.                         DO WHILE alen > 0
  949.                             IF alen <= 255 THEN
  950.                                 aln = alen
  951.                             ELSE
  952.                                 aln = 255
  953.                             CALL WRITECH('gfile', D2C(aln) || SUBSTR(annot, apos, aln))
  954.                             apos = apos + aln
  955.                             alen = alen - aln
  956.                         END
  957.                         CALL WRITECH('gfile', '00'x)
  958.                     END
  959.                 END
  960.                 ELSE DO
  961.                     CALL SEEK('tfile', 13, 'B')
  962.                     plt_data = READCH('tfile', plt_size)
  963.                     do_plt = (global_plt ~== local_plt)
  964.                 END
  965.  
  966.                 DO FOREVER
  967.                     code = READCH('tfile', 1)
  968.  
  969.                     IF code = ',' THEN DO   /* image */
  970.                         /* gfx control */
  971.                         CALL WRITECH('gfile', '21F904'x || pckinfo || IntelWord(delay.frm) || D2C(transpcol) || '00'x)
  972.  
  973.                         data = READCH('tfile', 9)       /* Get image descriptor */
  974.                         imginfo = SUBSTR(data, 9, 1)
  975.                         IF do_plt THEN
  976.                             imginfo = BITOR(BITAND(imginfo, '40'x), bxpix)
  977.  
  978.                         /* image descriptor */
  979.                         CALL WRITECH('gfile', ',' || IntelWord(dx0) || IntelWord(dy0) || IntelWord(dx1-dx0+1) || IntelWord(dy1-dy0+1) || imginfo)
  980.  
  981.                         IF do_plt THEN
  982.                             CALL WRITECH('gfile', plt_data)
  983.  
  984.                         tpos = SEEK('tfile', 0, 'C')
  985.                         epos = SEEK('tfile', 0, 'E')
  986.                         dsize = epos - tpos - 1
  987.                         CALL SEEK('tfile', tpos, 'B')
  988.  
  989.                         /* image data */
  990.                         DO WHILE dsize > 0
  991.                             IF dsize > 65000 THEN
  992.                                 tsize = 65000
  993.                             ELSE
  994.                                 tsize = dsize
  995.                             data = READCH('tfile', tsize)
  996.                             CALL WRITECH('gfile', data)
  997.                             dsize = dsize - tsize
  998.                         END
  999.                         BREAK
  1000.                     END
  1001.                     ELSE IF code = '!' THEN DO      /* extension */
  1002.                         CALL SEEK('tfile', 1, 'C')
  1003.                         length = 1
  1004.                         DO WHILE length ~= 0
  1005.                             length = C2D(READCH('tfile', 1))
  1006.                             IF length > 0 THEN
  1007.                                 CALL SEEK('tfile', length, 'C')
  1008.                         END
  1009.                     END
  1010.                     ELSE BREAK
  1011.                 END
  1012.  
  1013.                 CALL CLOSE('tfile')
  1014.             END
  1015.  
  1016.             CALL WRITECH('gfile', ';')
  1017.             CALL CLOSE('gfile')
  1018.             gfile_open = 0
  1019.  
  1020.             ADDRESS COMMAND 'Delete >NIL: 'tempfile
  1021.  
  1022.             SetCurrentBrush 'BRUSH' tbshnum
  1023.             IF RC = 0 THEN
  1024.                 FreeBrush 'FORCE'
  1025.  
  1026.             SetCurrentBrush 'BRUSH' bshnum
  1027.             IF RC = 0 THEN
  1028.                 SetBrushAttributes 'FRAMEFIRST' sv_frmin 'FRAMELAST' sv_frmax 'LENGTH' sv_frlen 'FRAMEPOSITION' sv_frpos
  1029.  
  1030.             Set '"ICONS =' sv_icons '"'
  1031.  
  1032.             FreeBitmap tbmap.1
  1033.         END
  1034.         ELSE err_msg = txt_err_nomem
  1035.  
  1036.         FreeBitmap tbmap.0
  1037.     END
  1038.     ELSE err_msg = txt_err_nomem
  1039.  
  1040.     IF err_msg ~= '' THEN
  1041.         RequestNotify 'PROMPT "'err_msg'"'
  1042.  
  1043.     Set '"PATHBSH=""'sv_pathbsh'"" "'
  1044. END
  1045. UnlockGUI
  1046.  
  1047. EXIT 0
  1048.  
  1049.  
  1050.  
  1051.  
  1052. IntelWord: PROCEDURE
  1053.  
  1054.     value = ARG(1)
  1055.  
  1056.     hibyte = value % 256
  1057.     lobyte = value - (hibyte * 256)
  1058.  
  1059.     RETURN D2C(lobyte) || D2C(hibyte)
  1060.  
  1061.  
  1062.  
  1063.  
  1064. Break_C:
  1065.  
  1066.     IF gfile_open THEN
  1067.         CALL CLOSE('gfile')
  1068.  
  1069.     ADDRESS COMMAND 'Delete >NIL: 'tempfile
  1070.  
  1071.     SetCurrentBrush 'BRUSH' tbshnum
  1072.     IF RC = 0 THEN
  1073.         FreeBrush 'FORCE'
  1074.  
  1075.     SetCurrentBrush 'BRUSH' bshnum
  1076.     IF RC = 0 THEN
  1077.         SetBrushAttributes 'FRAMEFIRST' sv_frmin 'FRAMELAST' sv_frmax 'LENGTH' sv_frlen 'FRAMEPOSITION' sv_frpos
  1078.  
  1079.     Set '"ICONS =' sv_icons '"'
  1080.  
  1081.     IF tbmap.1 ~= 0 THEN
  1082.         FreeBitmap tbmap.1
  1083.  
  1084.     IF tbmap.0 ~= 0 THEN
  1085.         FreeBitmap tbmap.0
  1086.  
  1087.     Set '"PATHBSH=""'sv_pathbsh'"" "'
  1088.  
  1089.     RETURN
  1090.